/**
////////////////////////////////////////////////////////////////////////////////
//                                                                            // 
//  Copyright (c) 2013 Santiago Benito Rebollo. Eclipse Public License - v 1.0//
//  @author Santiago Benito Rebollo.                                          // 
//  santiago.benito.rebollo@gmail.com                                         //
//                                                                            //  
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
// THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC// 
// LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM//
// CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.                      //
//                                                                            //
// A Contributor may choose to distribute the Program in object code form     //
// under its own license agreement, provided that:                            //
//                                                                            //
// a) it complies with the terms and conditions of this Agreement; and        //
// b) its license agreement:                                                  //
//                                                                            //
// i) effectively disclaims on behalf of all Contributors all warranties and  //
// conditions, express and implied, including warranties or conditions of     //  
// title and non-infringement, and implied warranties or conditions of        //
// merchantability and fitness for a particular purpose;                      //
// ii) effectively excludes on behalf of all Contributors all liability for   //
// damages, including direct, indirect, special, incidental and consequential //
// damages, such as lost profits;                                             //
// iii) states that any provisions which differ from this Agreement are       //
// offered by that Contributor alone and not by any other party; and          //
// iv) states that source code for the Program is available from such         //
// Contributor, and informs licensees how to obtain it in a reasonable        //
// manner on or through a medium customarily used for software exchange.      //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
 */

/**
CmIdentification
////////////////////////////////////////////////////////////////////////////////
// Version History:
// [Rev d.d dd Mmm yyyy hh:mm:ss    <logComment>]
$Log: Arista.java,v $
////////////////////////////////////////////////////////////////////////////////
 */

package com.chago.fastrecado;

/**
 * This class symbolize the edge object that join vertexes, with two weights: distance and time
 * 
 * @author Santiago Benito Rebollo
 * @author santiago.benito.rebollo@gmail.com
 */
public class Arista implements Comparable<Arista> {

	/**
    	The final vertex for this edge.
	*/ 
	public final Vertice target;
	/**
	Store how long the edge is. The value is passed depends on "distanceEnabled" to weigth
	 */ 
	public final double distance;
	/**
	Store how much time the edge is. The value is passed depends on "distanceEnabled" to weigth
	 */
	public final double time;
	/**
	The switch that is used for making algorithm runs with distance
	 */
	public boolean distanceEnabled=true;
	/**
	The switch that is used for making algorithm runs with time
	 */
	public boolean timeEnabled=false;	   

	/**
	This is the total weight of this node if you take this way to Vertice target
	 */	
	public double TotalWeigth=0;
	 /**
     * This method return the String with the name of the target vertex
     * 
     * @param Vertice none
     * @throws none Exception
     * @pre target != null
     * @post $none
     */
	public String getTargetName (){return target.toString();}

	/**
     * This method return the String with the name of the target vertex
     * 
     * @param Vertice none
     * @throws none Exception
     * @pre target != null
     * @post $none
     */	
	public double getDistance () {return distance;}
	
	/**
      * This method return the time value
      * 
      * @param none
      * @throws none Exception
      * @pre $none
      * @post $none
    */     
	public double getTime () {return time;}

	/**
     * This is the main constructor. Args are target vertex, distance and time
     * 
     * @param Vertice argTarget
     * @param double argDistance
     * @param double argTime
     * @throws none Exception
     * @pre argTarget!=null
     * @pre argDistance!=null
     * @pre argTime!=null
     * @post $none
   */     
	public Arista(Vertice argTarget, double argDistance,double argTime)	{ 
			target = argTarget; 
			distance = argDistance;
			time=argTime; 
	}

	/**
	* This method set the distanceEnabled switch to true and timeEnabled to false
	* 
	* @param  none
	* @throws none 
	* @pre $none
	* @post $none
	*/
	   public void enableDistance ()
	   { distanceEnabled=true; timeEnabled=false;}


	/**
	* This method set the timeEnabled switch to true and distanceEnabled to false
	* 
	* @param  none
	* @throws none 
	* @pre $none
	* @post $none
	*/
	 public void enableTime ()
	   { distanceEnabled=false; timeEnabled=true;}


	/**
	* This method return the weight of the edge depends on switches
	* 
	* @param  none
	* @throws none
	* @return double 
	* @pre $none
	* @post $none
	*/	 
	 public double getWeight (){
		   if (distanceEnabled) { return distance; }
		   else {return time;}
	   }
	 
	/**
	* This method overwrite implements the compareTo method of the interface Comparable
	* 
	* @param  Arista a
	* @return int
	* @throws none
	* @pre a!= null
	* @post $none
	*/	 
	 public int compareTo(Arista a)
	   { int result=1;
		   if (distanceEnabled) {
			   result = (this.distance < a.distance) ? -1: 1;
		   }
		   if (timeEnabled) {
			   result = (this.time < a.time) ? -1: 1;
		   }
	     return result;
	   }
}
